﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HMS_TabletClient
{
    public partial class UserListEdtor : Form
    {
        public UserListEdtor()
        {
            InitializeComponent();
        }
        public string author;
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Add(listBox2.Items[listBox2.SelectedIndex]);
                listBox1.SelectedIndex=listBox1.Items.Count-1;
                listBox2.Items.Remove(listBox2.Items[listBox2.SelectedIndex]);
            }
            catch 
            {

            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                listBox2.Items.Add(listBox1.Items[listBox1.SelectedIndex]);
                listBox1.Items.Remove(listBox1.Items[listBox1.SelectedIndex]);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                listBox2.SelectedIndex = listBox2.Items.Count - 1;
            }
            catch { }
        }

        private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
        {
            pictureBox2.BackColor = Color.LightBlue;
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            pictureBox2.BackColor = Color.Transparent;
            SelectAddr f3 = new SelectAddr();
            f3.Show();
            this.Hide();
            f3.FormClosed += new FormClosedEventHandler(f3_FormClosed);
            f3.author = author;
            f3.joined=new string[listBox1.Items.Count];
            for (int i = 1; i <= listBox1.Items.Count; i++)
            {
                f3.joined[i - 1] = listBox1.Items[i - 1].ToString();   
            }
            f3.sshow();
        }

        void f3_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Show();
            //throw new NotImplementedException();
        }

        private void pictureBox2_MouseLeave(object sender, EventArgs e)
        {
            pictureBox2.BackColor = Color.Transparent;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            pictureBox1.BackColor = Color.Transparent;
            this.Close();
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            pictureBox1.BackColor = Color.LightBlue;
        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            pictureBox1.BackColor = Color.Transparent;
        }

        private void UserListEdtor_Load(object sender, EventArgs e)
        {
            dateTimePicker1.Value = System.DateTime.Now;
            
        }
        public void sshow()
        {
            label5.Text += author;
        }
        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                listBox2.Items.Add(listBox1.Items[listBox1.SelectedIndex]);
                listBox1.Items.Remove(listBox1.Items[listBox1.SelectedIndex]);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                listBox2.SelectedIndex = listBox2.Items.Count - 1;
            }
            catch { }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                listBox3.Items.Add(listBox4.Items[listBox4.SelectedIndex]);
                listBox3.SelectedIndex = listBox3.Items.Count - 1;
                listBox4.Items.Remove(listBox4.Items[listBox4.SelectedIndex]);
            }
            catch
            {

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                listBox4.Items.Add(listBox3.Items[listBox3.SelectedIndex]);
                listBox3.Items.Remove(listBox3.Items[listBox3.SelectedIndex]);
                listBox3.SelectedIndex = listBox3.Items.Count - 1;
                listBox4.SelectedIndex = listBox4.Items.Count - 1;
            }
            catch { }
        }
    }
}
